﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MicroTest
{
    /// <summary>
    /// 学生标签
    /// </summary>
    /// [Serializable]
    [Serializable]
    class PenCardBand:StudentCard
    {
        public string PenSerial { set; get; }
    }
    [Serializable]
    class StudentInfo
    {
        //public string Grade { set; get; }
        public string Class { set; get; }
        public List<PenCardBand> BandList = new List<PenCardBand>();
        public void AddBandInfo(string penserial,StudentCard card)
        {
            foreach (var item in BandList)
            {
                if (item.PenSerial.Equals(penserial))
                    return;
            }
            PenCardBand pcb = new PenCardBand();
            pcb.CardHeight = card.CardHeight;
            pcb.CardWidth = card.CardWidth;
            pcb.LeftBound = card.LeftBound;
            pcb.Name = card.Name;
            pcb.PageId = card.PageId;
            pcb.PenSerial = penserial;
            pcb.TopBound = card.TopBound;
            BandList.Add(pcb);

        }
        public void ClearBindInfo()
        {
            BandList.Clear();
            Class = "";
        }
        public List<StudentCard> GetCardList()
        {
            List<StudentCard> cardList = new List<StudentCard>();
            foreach (var item in BandList)
            {
                StudentCard sc = new StudentCard();
                sc.CardHeight = item.CardHeight;
                sc.CardWidth = item.CardWidth;
                sc.LeftBound = item.LeftBound;
                sc.Name = item.Name;
                sc.PageId = item.PageId;
                sc.TopBound = item.TopBound;
                cardList.Add(sc);
            }
            return cardList;
        }
        public void UpdateCardPenSerial(string oldPenserial,string newPenserial)
        {
            foreach (var item in BandList)
            {
                if(oldPenserial.Equals(item.PenSerial))
                {
                    item.PenSerial = newPenserial;
                    break;
                }
            }
        }
    }
}
